package com.gouaixin.bee.beeframework2.activity;

import android.content.Context;
import android.content.Intent;
import android.graphics.Paint;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.google.gson.Gson;
import com.gouaixin.bee.beeframework2.R;
import com.gouaixin.bee.beeframework2.bean.Goods_id;
import com.gouaixin.bee.beeframework2.bean.Pay;
import com.gouaixin.bee.beeframework2.model.MemberModel;
import com.gouaixin.bee.beeframework2.tool.PreferencesUtils;
import com.gouaixin.bee.beeframework2.tool.mLog;

/**
 * Created by Administrator on 2015/3/10.
 */
//包月写信界面
public class B15_faxinBaoyueActivity extends FragmentActivity {
    Context context=B15_faxinBaoyueActivity.this;

    //顶部
    ImageView back;//返回
    TextView title;//标题

    TextView kt01,kt02,kt03,kt04;//立即开通
    TextView price01,price02,price03;//原价

    LinearLayout bg01,bg02,bg03,bg04;//充值项目整体

    String order="";//订单名
    String price="";//订单价格


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.b15_faxinbaoyue);


        cid= PreferencesUtils.getString(context, "cid");


        initView();

        setData();

        setListener();

    }

    private void initView() {

        back= (ImageView) findViewById(R.id.back);
        title= (TextView) findViewById(R.id.title);

        kt01= (TextView) findViewById(R.id.kt01);
        kt02= (TextView) findViewById(R.id.kt02);
        kt03= (TextView) findViewById(R.id.kt03);
        kt04= (TextView) findViewById(R.id.kt04);

        price01= (TextView) findViewById(R.id.price01);
        price02= (TextView) findViewById(R.id.price02);
        price03= (TextView) findViewById(R.id.price03);

        //设置中划线
        price01.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
        price02.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
        price03.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);

        bg01= (LinearLayout) findViewById(R.id.bg01);
        bg02= (LinearLayout) findViewById(R.id.bg02);
        bg03= (LinearLayout) findViewById(R.id.bg03);
        bg04= (LinearLayout) findViewById(R.id.bg04);

        //根据是否充值过，判断显示的充值项目
        MemberModel.haveRecharge(context, new MemberModel.HaveRechargeListener() {
            @Override
            public void onResult(boolean haveRecharge) {
                //如果充值过
                if (haveRecharge) {
                    bg03.setVisibility(View.GONE);
                    bg04.setVisibility(View.GONE);

                }
                //如果没充值过
                else {
                    bg03.setVisibility(View.VISIBLE);
                    bg04.setVisibility(View.VISIBLE);
                }
            }
        });



    }

    private void setData() {

    }

    private String order_name="",order_price="";
    private int goods_id;//商品的唯一id
    Pay bean=new Pay();
    String cid="";
    Intent it;
    private void setListener() {

        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        kt01.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                MemberModel.baoyueSuccess(context, BaoyueType.Type_1888);
                order_name="永久性包月写信";
                order_price="1888";

                bean.setAmount(order_price);
                bean.setCid(cid);
                bean.setTradeName(order_name);
                bean.setGoods_id(Goods_id.Baoyue_1888);

                it=new Intent(context,F1_PaySelectActivity.class);
                it.putExtra("pay",new Gson().toJson(bean));
                mLog.e("vip界面传出的pay=" + new Gson().toJson(bean));
                startActivity(it);

            }
        });

        kt02.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                MemberModel.baoyueSuccess(context, BaoyueType.Type_400);
                order_name="12个月包月写信";
                order_price="300";

                bean.setAmount(order_price);
                bean.setCid(cid);
                bean.setTradeName(order_name);
                bean.setGoods_id(Goods_id.Baoyue_300);

                it=new Intent(context,F1_PaySelectActivity.class);
                it.putExtra("pay",new Gson().toJson(bean));
                mLog.e("vip界面传出的pay=" + new Gson().toJson(bean));
                startActivity(it);

            }
        });

        kt03.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                MemberModel.baoyueSuccess(context, BaoyueType.Type_100);
                order_name="3个月包月写信";
                order_price="100";

                bean.setAmount(order_price);
                bean.setCid(cid);
                bean.setTradeName(order_name);
                bean.setGoods_id(Goods_id.Baoyue_100);

                it=new Intent(context,F1_PaySelectActivity.class);
                it.putExtra("pay",new Gson().toJson(bean));
                mLog.e("vip界面传出的pay=" + new Gson().toJson(bean));
                startActivity(it);
                

            }
        });

        kt04.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                MemberModel.baoyueSuccess(context, BaoyueType.Type_50);
                order_name="1个月包月写信";
                order_price="50";

                bean.setAmount(order_price);
                bean.setCid(cid);
                bean.setTradeName(order_name);
                bean.setGoods_id(Goods_id.Baoyue_50);

                it=new Intent(context,F1_PaySelectActivity.class);
                it.putExtra("pay",new Gson().toJson(bean));
                mLog.e("vip界面传出的pay=" + new Gson().toJson(bean));
                startActivity(it);

            }
        });

    }

}
